#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using EstateNuke.Data;
using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;

#endregion

namespace EstateNuke.BusinessSystem.Controls.EstateControls
{
    public partial class BuildingTitleControl : EstateNukeControl
    {
        private Building _currentBuilding;
        public BuildingTitleControl(Building building)
        {
            _currentBuilding = building;
            InitializeComponent();
        }

        private void BindBuildingTitle()
        {
            lblBuildingName.Text = _currentBuilding.DisplayName;
            if (_currentBuilding.BusinessTypeId == 1)
            {
                var lstRoomState = DBContext.GetAllRoomStates();
                foreach (var roomState in lstRoomState)
                {
                    BuildingTitleItemControl control = new BuildingTitleItemControl(_currentBuilding, roomState);
                    flpBuildingTitleItemContainer.Controls.Add(control);
                }
            }
            else
            {
                var lstRoomState = DBContext.PropertyStates.ToList();
                foreach (var roomState in lstRoomState)
                {
                    BuildingTitleLeaseItemControl control = new BuildingTitleLeaseItemControl(_currentBuilding, roomState);
                    flpBuildingTitleItemContainer.Controls.Add(control);
                }
            }
        }

        private void BuildingTitleControl_Load(object sender, EventArgs e)
        {
            BindBuildingTitle();
        }
    }
}